package game.utils;

import game.views.SkillDescView;
import game.data.FightAnalysisData;
import game.views.RoleLogView;
import game.views.RoleInfoView;
import game.assets.Hxwz2RolePackageFuture;
import game.data.Hxwz2RolePackageData;
import VectorMath.abs;
import game.assets.ABProjFuture;
import hx.assets.Assets;
import game.data.ProjectDataExport;
import game.worlds.GameWorld;
import game.data.ProjectRoleData;

using Reflect;

/**
 * 测试工具，它可以在控制台输入方法直接执行
 */
class TestTools {
	public static function init():Void {
		#if js
		var window = js.Browser.window;
		for (key in Reflect.fields(TestTools)) {
			window.setProperty(key, TestTools.getProperty(key));
		}
		#end
	}

	/**
	 * 测试新编辑器项目数据
	 */
	public static function testProjectRoleData():Void {
		// 测试项目读取
		// var assets = new Assets();
		// assets.loadString("assets/test/AnimeBattleCharacterEditer.abproj");
		// assets.onComplete((a) -> {
		// 	var project = new ProjectRoleData(assets.strings.get("AnimeBattleCharacterEditer"));
		// 	trace("project=", project);
		// 	trace("project.actions", project.actions.get("落地"));
		// });
		// assets.start();

		var future = new ABProjFuture("roleProject/BoFengShuiMeng.abproj");
		future.onComplete(e -> {
			trace("加载完成");
		}).onError(err -> {
			trace("加载失败", err);
		});
		future.post();
	}

	/**
	 * 测试项目资源导出
	 */
	public static function exportProjectRoleData():Void {
		// 测试项目读取
		var future = new Hxwz2RolePackageFuture("assets/roles/BFSM.data");
		future.onComplete(roleAssets -> {
			var export = new ProjectDataExport(roleAssets.data);
			var json = export.export();
			trace("project", json);
		}).onError(err -> {
			trace("加载失败", err);
		});
		future.post();
	}

	/**
	 * 设置世界是否渲染调试信息
	 * @param bool 
	 */
	public static function setDebug(bool:Bool):Void {
		GameWorld.currentWorld.debug = bool;
	}
}
